import { invokeRPC } from "@/ui/utils/rpc/helpers";
import { SystemConfig } from "@common/meta";

export const getAll = async () => {
  return invokeRPC({
    rpcName: "app.settings.getAll",
    rpcParams: {},
    receiver: "plugin",
  }) as Promise<SystemConfig>;
};

export const setAll = async (settings: Record<string, string>) => {
  return invokeRPC({
    rpcName: "app.settings.setAll",
    rpcParams: settings,
    receiver: "plugin",
  }) as Promise<void>;
};

export const get = async (key: string) => {
  return invokeRPC({
    rpcName: "app.settings.get",
    rpcParams: { key },
    receiver: "plugin",
  }) as Promise<string>;
};

export const set = async (key: string, value: string) => {
  return invokeRPC({
    rpcName: "app.settings.set",
    rpcParams: { key, value },
    receiver: "plugin",
  }) as Promise<void>;
};
